# Python 2.6.4
# Project Euler, Problem 58
# Copyright 2010 Talha Zaman

from math import sqrt
def isprime(n):
    sn = sqrt(n)+1
    for i in range(2,sn+1):
        if n%i==0: return False
    return True

def spiral():
    n, inc, count = 1, 2, 0
    while 1:
        n += inc
        count += 1
        if count==4:
            count = 0
            inc += 2
        yield n

primes = 0
count = 1
length = 1
S = spiral()
while 1:
    for i in range(4): primes += isprime(S.next())
    count += 4
    length += 2
#    print "Length:", length, "Primes:", primes, "/", count
    if primes*10 < count: break

print "Length:", length, "Primes:", primes, "/", count
